{* Smarty *}
{literal}
<style type="text/css">
.window_banner{width:100%;height:100%;position:absolute;top:0;left:0;display:none;background:url(/templates/admin/img/bg.black.70.png) repeat;z-index:12000;}
.window_banner .b{width:500px;height:500px;position:absolute;border:4px white solid;background:white;top:50%;left:50%;z-index:1002;margin:-250px 0 0 -250px;}
.window_banner .b .close{position:absolute;display:none;margin:-15px 0 0 490px;width:30px;height:29px;background:url(/templates/admin/img/close.png) no-repeat 0 0;cursor:pointer;}
.loader_ajax_change_group{width:32px;height:32px;background:url(/templates/admin/img/loading.gif) no-repeat 0 0;position:absolute;margin:234px 0 0 234px;z-index:1004;display:none;}
</style>
{/literal}


<a href="/admin/?m=structure&parent={$smarty.get.parent}" class="change_name_group" title="Обзор подразделов" style="font-weight:bold;">{$curr_name}</a> &nbsp; 
<a href="javascript:void(0);" class="change_group butt_rad_grad_grey" table="{$table}" parent="{$smarty.get.parent}" curr_id="{$smarty.get.id}">Сменить раздел</a>
<input type="hidden" name="parent" value="{if $smarty.get.parent}{$smarty.get.parent}{else}1{/if}" class="active_group" />
<div class="window_banner">
  <div class="b">
    <div class="close" title="Закрыть"></div>
    <div class="loader_ajax_change_group"></div>
    <select size="12" style="font-size:10px;width:100%;height:500px;"></select>
  </div>
</div>
<script type="text/javascript">
$(function()
{
	$(".change_group").live("click", function()
	{
		$(".window_banner").fadeIn(500);
		$("html").css({
			overflow:"hidden"
		});				
		if($(".window_banner .b select").text() == "")
		{
			$(".loader_ajax_change_group").show();
			var table = $(this).attr("table");
			var parent   = $(this).attr("parent");
			var curr_id  = $(this).attr("curr_id");
			$.post("/ajax/admin/change_group_select.backend.php",{
				"table"   : table,
				"parent"  : parent,
				"curr_id" : curr_id
			},function(data){
				$(".window_banner .b select").html(data);
				$(".loader_ajax_change_group").hide();
				$(".close").fadeIn();
			}, 
			"html");
		}				
		return false;								
	});	
	$(".close").live("click", function(){
		$(".window_banner").fadeOut(500);
		setTimeout(function(){
			$("html").css({
				overflow:"auto"
			});
		}, 510);				
	});
	
	$(".window_banner .b select").live("change", function(){
		var text = $("option:checked", $(this)).text().split("| — ");				
		var id_g = $("option:checked", $(this)).attr("value");
		if(id_g == "undefined") {
			id_g = "0";
		}				
		
		if(text.length == 1) {
			var text_new = text[0];
		}
		else if(text.length == 2) {
			var text_new = text[1];
		}
		else {
			alert("Error!");	
		}				
		
		$(".change_name_group").html(text_new).attr("href", "/admin/?m=structure&parent="+id_g);
		$(".active_group").attr("value", id_g);
	});
});
</script>